package com.example.administrator.androidros.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.administrator.androidros.R;
import com.example.administrator.androidros.model.MessageModel;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by Administrator on 2018/1/22.
 */

public class MessageAdapter extends BaseQuickAdapter<MessageModel, BaseViewHolder> {
    public MessageAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageModel item) {
//        helper.setImageResource(R.id.fragment_home_page_item_notification_img_icon, item.getImageResource());
        //10:设备上线  20：权限申请
        if (item.getMessageType().equals("10")) {
            helper.setImageResource(R.id.message_item_img_icon, R.mipmap.ic_launcher);
        } else if (item.getMessageType().equals("20")) {
            helper.setImageResource(R.id.message_item_img_icon, R.mipmap.ic_launcher_round);
        }
        helper.setText(R.id.message_item_tv_type, item.getMessageTitle());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        helper.setText(R.id.message_item_tv_time, sdf.format(item.getInsertTime()));

//        helper.setText(R.id.fragment_home_page_item_notification_tv_title, item.getMessageTitle());
        helper.setText(R.id.message_item_tv_title, item.getMessageContent());
        helper.addOnClickListener(R.id.message_item_img_more);
//        Glide.with(mContext).load(item.getImageUrl()).crossFade().into((ImageView) helper.getView(R.id.fragment_home_page_item_notification_img_icon));
    }
}
